from manim import *
class CustomCurve(VMobject):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        # 定义自定义曲线的控制点
        points = [
            [-20, 12.5, 0],
            [-21,11.5,0],
            [-22,-1.5,0],
            [-24, 0, 0],
            [-22,-1.5,0],
            [-21,-11.5,0],
            [-20, -12.5, 0]
        ]
        self.set_points_smoothly(points)


class math1(MovingCameraScene):
    def construct(self):
        self.camera.background_color = BLACK  # 设置背景颜色
        self.camera.frame_width = 100  # 设置边框宽度
        self.camera.frame_height = 60  # 设置边框高度
        self.camera.pixel_height = 1080  # 设置像素高度
        self.camera.pixel_width = 1920  # 设置像素宽度
        self.camera.center = ORIGIN  # 设置中心点位置
        self.camera.scale_factor = 1.0  # 设置缩放因子
        #设置横线
        for i in range(6*2+1):       
            dot1=Dot([-50,5*(i-6),0]).set_opacity(0.5)
            dot2=Dot([50,5*(i-6),0]).set_opacity(0.5)
            if i==6:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
                
            else:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
               
            self.add(dot1,dot2,line1)
        #设置竖线
        for i in range(10*2+1):        
            dot3=Dot([(i-10)*5,-30,0]).set_opacity(0.5)
            dot4=Dot([(i-10)*5,30,0]).set_opacity(0.5)
            if i==10:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
                
            else:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
            self.add(dot3,dot4,line2)
        #设置三个点
        dot1 = Dot(radius=1, color=RED)  
        dot1.move_to([-47.5,27.5,0]) 
        dot2 = Dot(radius=1, color=YELLOW)  
        dot2.move_to([-42.5,27.5,0])  
        dot3 = Dot(radius=1, color=GREEN)  
        dot3.move_to([-37.5,27.5,0])
        



        #1文本
        text5 = Tex(
                    r"\text{结构化思维应用}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-35,0,0])
        #2框框标
        rectangle1=Rectangle(color=BLUE,fill_opacity=0.0,width=20,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle1.move_to([-35,0,0])
        self.play(Write(text5),Create(rectangle1))
       #镜头跟进效果 
        self.camera.frame.save_state()

        curve = CustomCurve(color=RED, stroke_width=20)
        
        # 添加到场景并播放动画
        self.play(Create(curve))
        #4文本
        text60 = Tex(
                    r"\text{知识点结构化(低阶)}",color=GREEN_C
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-8,12.5,0])
        text70 = Tex(
                    r"\text{题型结构化(中阶)}",color=GREEN_C
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-8,0,0])
        text80 = Tex(
                    r"\text{思路结构化(高阶)}",color=GREEN_C
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-8,-12.5,0])
       
        
        
        self.play(Create(text60),Create(text70),Create(text80))
        #2框框标
        rectangle2=Rectangle(color=BLUE,fill_opacity=0.0,width=20,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle2.move_to([-8,12.5,0])
        self.play(Create(rectangle2))
        self.play(FadeOut(rectangle2))
        #2框框标
        rectangle2=Rectangle(color=BLUE,fill_opacity=0.0,width=20,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle2.move_to([-8,0,0])
        self.play(Create(rectangle2))
        self.play(FadeOut(rectangle2))
        #2框框标
        rectangle2=Rectangle(color=BLUE,fill_opacity=0.0,width=20,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle2.move_to([-8,-12.5,0])
        self.play(Create(rectangle2))
        self.play(FadeOut(rectangle2))
        
        #4文本
        text1= Tex(
                    r"\text{知识点}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-20,23,0])
         #4文本
        text2= Tex(
                    r"\text{二次整理}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,26,0])
         #4文本
        text3= Tex(
                    r"\text{知识结构}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([20,23,0])
        arrow = Arrow(start=[-15,23,0],end=[15,23,0],color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(text1))
        self.play(GrowArrow(arrow),Create(text2))
        self.play(Create(text3))
        #4文本
        text6 = Tex(
                    r"\text{知识点浓缩}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([25,14.5,0])
        text7 = Tex(
                    r"\text{注意力聚焦}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([25,10.5,0])
        text8 = Tex(
                    r"\text{0}$\rightarrow $\text{90分}",color=WHITE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text60,UP,buff=1)
        text9 = Tex(
                    r"\text{入门}",color=YELLOW
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([42,12.5,0])
        self.play(
            ReplacementTransform(text1,text6),
            ReplacementTransform(text2,text7),
            ReplacementTransform(text3,text6),
            ReplacementTransform(arrow,text7)
        )
        self.play(Create(text8))
        self.play(Create(text9))
        self.wait(0.5)


         #4文本
        text1= Tex(
                    r"\text{题型}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-20,23,0])
         #4文本
        text2= Tex(
                    r"\text{二次整理}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,26,0])
         #4文本
        text3= Tex(
                    r"\text{知识点}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([20,23,0])
        #4文本
        text4= Tex(
                    r"\text{知识结构}",color=YELLOW
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([20,23,0])
         #4文本
        text5= Tex(
                    r"\text{知识联系}",color=PURE_GREEN
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,26,0])
        arrow = Arrow(start=[-15,23,0],end=[15,23,0],color=RED
                       , stroke_width=20, tip_length=1)
        self.play(Create(text1))
        
        self.play(Create(text3))
        self.play(GrowArrow(arrow),Create(text2))
        self.play(
            ReplacementTransform(text3,text4),
            
        )
        #4文本
        text700= Tex(
                    r"\text{(一维)}",color=RED
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text1,LEFT)
        #4文本
        text800= Tex(
                    r"\text{(二维)}",color=RED
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text4,RIGHT)
        self.play(Create(text700))
        
        self.play(Create(text800))
        self.play(
            ReplacementTransform(text2,text5),
            
        )


        #4文本
        text6 = Tex(
                    r"\text{信息表达维度的升高}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([25,2,0])
        text7 = Tex(
                    r"\text{降维打击效果}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([25,-2,0])
        text8 = Tex(
                    r"\text{90}$\rightarrow $\text{120分}",color=WHITE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text70,UP,buff=1)
        text9 = Tex(
                    r"\text{高手}",color=YELLOW
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([42,0,0])
        
        self.play(
            ReplacementTransform(text1,text6),
            ReplacementTransform(text5,text7),
            ReplacementTransform(text4,text8),
            ReplacementTransform(arrow,text9),
            ReplacementTransform(text700,text8),
            ReplacementTransform(text800,text9)
        )


        #4文本
        text6 = Tex(
                    r"\text{彻底领悟结构化本质}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([25,-10.5,0])
        text7 = Tex(
                    r"\text{开启上帝视角}",color=PURPLE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([25,-14.5,0])
        text8 = Tex(
                    r"\text{120}$\rightarrow $\text{140分}",color=WHITE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text80,UP,buff=1)
        text9 = Tex(
                    r"\text{半神}",color=YELLOW
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([42,-12.5,0])
        self.play(Create(text8))
        self.play(Create(text6),Create(text7))
        self.play(Create(text9))
        #2框框标
        rectangle2=Rectangle(color=BLUE,fill_opacity=0.0,width=24,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle2.move_to([25,-10.5,0])
        self.play(Create(rectangle2))
        #2框框标
        rectangle3=Rectangle(color=BLUE,fill_opacity=0.0,width=18,height=5
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle3.move_to([25,-14.5,0])
        self.play(
            ReplacementTransform(rectangle2,rectangle3),
           
        )
        text10 = Tex(
                    r"\text{特征识别}",color=PURE_RED
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([7,-20,0])
        self.play(
            ReplacementTransform(rectangle3,text10)
           
        )
        arrow1 = Arrow(start=[-35,-5,0],end=[-30,-20,0],color=BLUE
                       , stroke_width=20, tip_length=1)
        
        self.play(GrowArrow(arrow1))

        text11 = Tex(
                    r"\text{逻辑链条}",color=YELLOW
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-21,-20,0])
        self.play(Create(text11))

        arrow2 = Arrow(start=[-12,-20,0],end=[0,-20,0],color=BLUE
                       , stroke_width=20, tip_length=1)
        
        self.play(GrowArrow(arrow2))
        text12 = Tex(
                    r"\text{可视化思维}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(8.0).move_to([0,22,0])
        self.play(
            ReplacementTransform(text11,text12),
            ReplacementTransform(arrow2,text12),
            ReplacementTransform(arrow1,text12),
            ReplacementTransform(text10,text12),
            
        )
        self.wait()